package com.gsafety.wellsfort.controller.knowledge;

import com.gsafety.wellsfort.common.util.ApiResponse;
import com.gsafety.wellsfort.domain.dto.ids.TeachingAidIdDTO;
import com.gsafety.wellsfort.domain.dto.teachaid.TeachingAidDTO;
import com.gsafety.wellsfort.domain.dto.teachaid.TeachingAidQueryDTO;
import com.gsafety.wellsfort.domain.model.knowledge.TeachingAid;
import com.gsafety.wellsfort.domain.vo.CoursewareVO;
import com.gsafety.wellsfort.domain.vo.TeachingAidVO;
import com.gsafety.wellsfort.service.knowledge.TeachingAidService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(value = "教具管理", description = "教具管理接口")
@RestController
@Slf4j
@RequestMapping("/api/teachaid")
public class TeachingAidController {
    @Autowired
    private TeachingAidService teachingAidService;

    @ApiOperation(value = "保存教具")
    @PostMapping("/save")
    public ApiResponse<TeachingAidDTO> saveTeachingAid(@RequestBody TeachingAidDTO teachingAid) {
        return teachingAidService.saveTeachingAid(teachingAid);
    }

    @ApiOperation(value = "删除教具")
    @PostMapping("/remove")
    public ApiResponse deleteTeachingAid(@RequestBody TeachingAidIdDTO idDTO) {
        return teachingAidService.deleteByTeachingAidId(idDTO.getTeachingAidId());
    }

    @ApiOperation(value = "查看或编辑教具")
    @PostMapping("/get")
    public ApiResponse<TeachingAidVO> getTeachingAid(@RequestBody TeachingAidIdDTO idDTO) {
        return teachingAidService.getTeachingAid(idDTO.getTeachingAidId());
    }

    @ApiOperation(value = "查询教具")
    @PostMapping("/list")
    public ApiResponse<List<TeachingAidVO>> findByPageParams(@RequestBody TeachingAidQueryDTO dtoParams) {
        return teachingAidService.findByPageParams(dtoParams);
    }


    @ApiOperation(value = "根据角色,获取可以使用的教具列表")
    @PostMapping("/getAllByRole")
    public ApiResponse<List<TeachingAid>> getAllByRole() {
        return teachingAidService.getAllByRole();
    }
}
